import Vue from 'vue'
import App from './App'
import router from './router'
import store from "./store"
import Vant from 'vant'
import 'vant/lib/index.css'
import Axios from "./common/axios"
import storage from "./common/storage"
import ws from "./common/ws"

Vue.config.productionTip = false
Vue.use(Vant)
Vue.use(ws)
Vue.prototype.$axios = Axios
Vue.prototype.STORAGE = storage

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})


/*全局路由控制*/
router.beforeEach((to, from, next) => {
  if (to.meta.requireAuth || from.meta.requireAuth) {
    if (storage.getString("token") != null) {
      next()
    } else {
      next({
        path: '/login',
      })
    }
  } else {
    next()
  }
});

